﻿namespace Microsoft.SharePoint.Client
{
    using System;
    using System.ComponentModel;

    [ScriptType("SP.FieldDateTime", ServerTypeId="{4f9dc9b4-d900-40eb-94b9-008abbfb22e1}")]
    public class FieldDateTime : Field
    {
        [EditorBrowsable(EditorBrowsableState.Never)]
        public FieldDateTime(ClientRuntimeContext Context, ObjectPath ObjectPath) : base(Context, ObjectPath)
        {
        }

        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            bool flag = base.InitOnePropertyFromJson(peekedName, reader);
            if (!flag)
            {
                string str = peekedName;
                if (str == null)
                {
                    return flag;
                }
                if (!(str == "DateTimeCalendarType"))
                {
                    if (str == "DisplayFormat")
                    {
                        flag = true;
                        reader.ReadName();
                        base.ObjectData.Properties["DisplayFormat"] = reader.ReadEnum<DateTimeFieldFormatType>();
                    }
                    return flag;
                }
                flag = true;
                reader.ReadName();
                base.ObjectData.Properties["DateTimeCalendarType"] = reader.ReadEnum<CalendarType>();
            }
            return flag;
        }

        [Remote]
        public CalendarType DateTimeCalendarType
        {
            get
            {
                base.CheckUninitializedProperty("DateTimeCalendarType");
                return (CalendarType) base.ObjectData.Properties["DateTimeCalendarType"];
            }
            set
            {
                base.ObjectData.Properties["DateTimeCalendarType"] = value;
                if (base.Context != null)
                {
                    base.Context.AddQuery(new ClientActionSetProperty(this, "DateTimeCalendarType", value));
                }
            }
        }

        [Remote]
        public DateTimeFieldFormatType DisplayFormat
        {
            get
            {
                base.CheckUninitializedProperty("DisplayFormat");
                return (DateTimeFieldFormatType) base.ObjectData.Properties["DisplayFormat"];
            }
            set
            {
                base.ObjectData.Properties["DisplayFormat"] = value;
                if (base.Context != null)
                {
                    base.Context.AddQuery(new ClientActionSetProperty(this, "DisplayFormat", value));
                }
            }
        }
    }
}

